package com.ruoyi.system.mapper;

import com.ruoyi.system.domain.SysNews;
import com.ruoyi.system.domain.SysTask;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ClassName: NewsMapper <br/>
 * Description: <br/>
 * date: 2020/3/24 9:46<br/>
 *
 * @author Hesion<br />
 * @since JDK 1.8
 */
@Mapper
public interface NewsMapper {
    @Select("SELECT * FROM sys_news  where del_flag = '0'")
    @Results(id = "SysNewsManageResult",
            value = {
                    @Result(property = "createTime", column = "create_time"),
                    @Result(property = "updateTime", column = "update_time"),
                    @Result(property = "updateBy", column = "update_by"),
                    @Result(property = "createBy", column = "create_by"),
            })
    List<SysNews> selectNewsList(SysNews sysNews);

    @Select("SELECT * FROM sys_news WHERE id=#{id}")
    SysNews selectNewsById(String id);

    @Update("UPDATE sys_news SET title=#{title},content=#{content},update_by=#{updateBy},update_time=#{updateTime} WHERE id=#{id}")
    Integer edit(SysNews sysNews);

    @Delete("DELETE FROM sys_news WHERE id =#{id}")
    Integer remove(String id);

    @Insert("INSERT INTO sys_news(title,content,imgurl,create_time,create_by,update_time,update_by,del_flag) VALUES(#{title},#{content},#{imgurl},#{createTime},#{createBy},#{updateTime},#{updateBy},#{del_flag})")
    Integer add(SysNews sysNews);
}
